{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#调试存储方式，研究如何存储数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#研究这个代码存储问题，解决和相应的geturl问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>author</th>\n",
       "      <th>bookname</th>\n",
       "      <th>classes</th>\n",
       "      <th>content</th>\n",
       "      <th>number</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>卧牛真人</td>\n",
       "      <td>修真四万年</td>\n",
       "      <td>科幻</td>\n",
       "      <td>“倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！...</td>\n",
       "      <td>1040.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>贱宗首席弟子</td>\n",
       "      <td>大魏宫廷</td>\n",
       "      <td>历史</td>\n",
       "      <td>生作大魏皇子，愿当盛世闲王。志在偎红倚翠犬马声色，胸怀家国百姓社稷安危。若兄贤，若弟明，尔为...</td>\n",
       "      <td>674.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>王梓钧</td>\n",
       "      <td>民国之文豪崛起</td>\n",
       "      <td>历史</td>\n",
       "      <td>周赫煊回到民国时代，不会带兵打仗，不懂科学技术，不喜从政从商，那他还能干什么？唉，抄书抄诗混...</td>\n",
       "      <td>249.66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>寒门 二次元</td>\n",
       "      <td>奶爸的文艺人生</td>\n",
       "      <td>都市</td>\n",
       "      <td>“粑粑！”刚穿越到平行世界，就看到有个精致可爱的小女孩喊自己爸爸，杨轶表示有些懵逼。好吧，曦...</td>\n",
       "      <td>315.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>二将</td>\n",
       "      <td>国际制造商</td>\n",
       "      <td>都市</td>\n",
       "      <td>韩义在路上扫了个二维码，然后桌面上多了个应用。这个应用很奇怪，它可以捕捉到现实里的一切物品，...</td>\n",
       "      <td>216.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>卖报小郎君</td>\n",
       "      <td>我的姐姐是大明星</td>\n",
       "      <td>都市</td>\n",
       "      <td>某年某月某天，姐姐忽然说：“我要做明星。”秦泽淡定道：“老姐，你想被老爹活活打死，我不反对。...</td>\n",
       "      <td>215.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>孤单地飞</td>\n",
       "      <td>神道丹尊</td>\n",
       "      <td>玄幻</td>\n",
       "      <td>绝世强者、一代丹帝凌寒为追求成神之路而殒落，万年后携《不灭天经》重生于同名少年，从此风云涌动...</td>\n",
       "      <td>1019.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>蝴蝶蓝</td>\n",
       "      <td>全职高手</td>\n",
       "      <td>游戏</td>\n",
       "      <td>网游荣耀中被誉为教科书级别的顶尖高手，因为种种原因遭到俱乐部的驱逐，离开职业圈的他寄身于一家...</td>\n",
       "      <td>535.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>白色十三号</td>\n",
       "      <td>最佳影星</td>\n",
       "      <td>都市</td>\n",
       "      <td>新书《魔气熏天》已发布我要躺在钞票堆里打滚！我要做好莱坞巨星！群：323320648。</td>\n",
       "      <td>311.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>忘语</td>\n",
       "      <td>凡人修仙传</td>\n",
       "      <td>仙侠</td>\n",
       "      <td>一个普通山村小子，偶然下进入到当地江湖小门派，成了一名记名弟子。他以这样身份，如何在门派中立...</td>\n",
       "      <td>744.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>远古莱德</td>\n",
       "      <td>篮坛活菩萨</td>\n",
       "      <td>体育</td>\n",
       "      <td>喜获《日行一善》系统，做善事，得奖励，走上篮坛巅峰！……“自打雷风进入了NBA，整个NBA就...</td>\n",
       "      <td>105.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>李鸿天 二次元</td>\n",
       "      <td>异世界的美食家</td>\n",
       "      <td>玄幻</td>\n",
       "      <td>在武者举手可裂山川，甩腿可断长河的玄幻世界中，存在着这样一家小餐馆。小餐馆不大，但却是无数顶...</td>\n",
       "      <td>616.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>鹅是老五</td>\n",
       "      <td>最强弃少</td>\n",
       "      <td>仙侠</td>\n",
       "      <td>叶默蓦然清醒过来的时候，才发现周围的一切似乎都变了，美女师父也不见了。他也发现了自己成了被世...</td>\n",
       "      <td>704.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>天帝大人</td>\n",
       "      <td>穿越诸天万界</td>\n",
       "      <td>武侠</td>\n",
       "      <td>一花一世界，一叶一菩提，水浒三国，聊斋白蛇，蜀山斗破，阳神遮天，封神洪荒，诸天万界……穿梭诸...</td>\n",
       "      <td>212.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>我是贝币</td>\n",
       "      <td>一拳超人之帝王引擎</td>\n",
       "      <td>二次元</td>\n",
       "      <td>现代人穿越到一拳超人世界，成为了king，他表示：我是运气使然的英雄，也是地表最强的男人……...</td>\n",
       "      <td>123.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>天蚕土豆</td>\n",
       "      <td>斗破苍穹</td>\n",
       "      <td>玄幻</td>\n",
       "      <td>这里是属于斗气的世界，没有花俏艳丽的魔法，有的，仅仅是繁衍到巅峰的斗气！新书等级制度：斗者，...</td>\n",
       "      <td>526.09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>唐家三少</td>\n",
       "      <td>斗罗大陆</td>\n",
       "      <td>玄幻</td>\n",
       "      <td>唐门外门弟子唐三，因偷学内门绝学为唐门所不容，跳崖明志时却发现没有死，反而以另外一个身份来到...</td>\n",
       "      <td>298.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>辰东</td>\n",
       "      <td>遮天</td>\n",
       "      <td>仙侠</td>\n",
       "      <td>冰冷与黑暗并存的宇宙深处，九具庞大的龙尸拉着一口青铜古棺，亘古长存。这是太空探测器在枯寂的宇...</td>\n",
       "      <td>632.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>雪落君</td>\n",
       "      <td>宿主请留步</td>\n",
       "      <td>科幻</td>\n",
       "      <td>宿主请留步！系统还有三十秒抵达战场。故事，从苏洛玩炸了系统后，翻身兼职干系统开始。</td>\n",
       "      <td>179.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>暴兵对A</td>\n",
       "      <td>随身带着星际争霸</td>\n",
       "      <td>科幻</td>\n",
       "      <td>一觉醒来，唐方穿越到253年后的星河时代，成为一名前线炮灰士兵。他发现自己竟然随身带着一款即...</td>\n",
       "      <td>671.53</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     author   bookname classes  \\\n",
       "0      卧牛真人      修真四万年      科幻   \n",
       "1    贱宗首席弟子       大魏宫廷      历史   \n",
       "2       王梓钧    民国之文豪崛起      历史   \n",
       "3    寒门 二次元    奶爸的文艺人生      都市   \n",
       "4        二将      国际制造商      都市   \n",
       "5     卖报小郎君   我的姐姐是大明星      都市   \n",
       "6      孤单地飞       神道丹尊      玄幻   \n",
       "7       蝴蝶蓝       全职高手      游戏   \n",
       "8     白色十三号       最佳影星      都市   \n",
       "9        忘语      凡人修仙传      仙侠   \n",
       "10     远古莱德      篮坛活菩萨      体育   \n",
       "11  李鸿天 二次元    异世界的美食家      玄幻   \n",
       "12     鹅是老五       最强弃少      仙侠   \n",
       "13     天帝大人     穿越诸天万界      武侠   \n",
       "14     我是贝币  一拳超人之帝王引擎     二次元   \n",
       "15     天蚕土豆       斗破苍穹      玄幻   \n",
       "16     唐家三少       斗罗大陆      玄幻   \n",
       "17       辰东         遮天      仙侠   \n",
       "18      雪落君      宿主请留步      科幻   \n",
       "19     暴兵对A   随身带着星际争霸      科幻   \n",
       "\n",
       "                                              content   number  \n",
       "0   “倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！...  1040.22  \n",
       "1   生作大魏皇子，愿当盛世闲王。志在偎红倚翠犬马声色，胸怀家国百姓社稷安危。若兄贤，若弟明，尔为...   674.68  \n",
       "2   周赫煊回到民国时代，不会带兵打仗，不懂科学技术，不喜从政从商，那他还能干什么？唉，抄书抄诗混...   249.66  \n",
       "3   “粑粑！”刚穿越到平行世界，就看到有个精致可爱的小女孩喊自己爸爸，杨轶表示有些懵逼。好吧，曦...   315.06  \n",
       "4   韩义在路上扫了个二维码，然后桌面上多了个应用。这个应用很奇怪，它可以捕捉到现实里的一切物品，...   216.12  \n",
       "5   某年某月某天，姐姐忽然说：“我要做明星。”秦泽淡定道：“老姐，你想被老爹活活打死，我不反对。...   215.96  \n",
       "6   绝世强者、一代丹帝凌寒为追求成神之路而殒落，万年后携《不灭天经》重生于同名少年，从此风云涌动...  1019.58  \n",
       "7   网游荣耀中被誉为教科书级别的顶尖高手，因为种种原因遭到俱乐部的驱逐，离开职业圈的他寄身于一家...   535.02  \n",
       "8         新书《魔气熏天》已发布我要躺在钞票堆里打滚！我要做好莱坞巨星！群：323320648。   311.45  \n",
       "9   一个普通山村小子，偶然下进入到当地江湖小门派，成了一名记名弟子。他以这样身份，如何在门派中立...   744.75  \n",
       "10  喜获《日行一善》系统，做善事，得奖励，走上篮坛巅峰！……“自打雷风进入了NBA，整个NBA就...   105.54  \n",
       "11  在武者举手可裂山川，甩腿可断长河的玄幻世界中，存在着这样一家小餐馆。小餐馆不大，但却是无数顶...   616.06  \n",
       "12  叶默蓦然清醒过来的时候，才发现周围的一切似乎都变了，美女师父也不见了。他也发现了自己成了被世...   704.19  \n",
       "13  一花一世界，一叶一菩提，水浒三国，聊斋白蛇，蜀山斗破，阳神遮天，封神洪荒，诸天万界……穿梭诸...   212.07  \n",
       "14  现代人穿越到一拳超人世界，成为了king，他表示：我是运气使然的英雄，也是地表最强的男人……...   123.42  \n",
       "15  这里是属于斗气的世界，没有花俏艳丽的魔法，有的，仅仅是繁衍到巅峰的斗气！新书等级制度：斗者，...   526.09  \n",
       "16  唐门外门弟子唐三，因偷学内门绝学为唐门所不容，跳崖明志时却发现没有死，反而以另外一个身份来到...   298.95  \n",
       "17  冰冷与黑暗并存的宇宙深处，九具庞大的龙尸拉着一口青铜古棺，亘古长存。这是太空探测器在枯寂的宇...   632.31  \n",
       "18          宿主请留步！系统还有三十秒抵达战场。故事，从苏洛玩炸了系统后，翻身兼职干系统开始。    179.5  \n",
       "19  一觉醒来，唐方穿越到253年后的星河时代，成为一名前线炮灰士兵。他发现自己竟然随身带着一款即...   671.53  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests,json,time,re\n",
    "from requests.exceptions import RequestException\n",
    "from pyquery import PyQuery as pq\n",
    "from fontTools.ttLib import TTFont\n",
    "from io import BytesIO\n",
    "import pandas as pd\n",
    "\n",
    " \n",
    "start_url = 'https://www.qidian.com/finish?action=hidden&orderId=&style=1&pageSize=20&siteid=1&pubflag=0&hiddenField=2&page=1'\n",
    " \n",
    "def get_font(url):\n",
    "    response = requests.get(url)\n",
    "    font = TTFont(BytesIO(response.content))\n",
    "    cmap = font.getBestCmap()\n",
    "    font.close()\n",
    "    return cmap\n",
    " \n",
    "def get_encode(cmap,values):\n",
    "    WORD_MAP = {'zero':'0','one':'1','two':'2','three':'3','four':'4','five':'5','six':'6','seven':'7','eight':'8','nine':'9','period':'.'}\n",
    "    word_count=''\n",
    "    for value in values.split(';'):\n",
    "        value = value[2:]\n",
    "        key = cmap[int(value)]\n",
    "        word_count += WORD_MAP[key]\n",
    "    return word_count\n",
    " \n",
    "def get_index(start_url):\n",
    "    #获取当前页面的html\n",
    "    response = requests.get(start_url).text   \n",
    "    doc = pq(response)\n",
    "    #获取当前字体文件名称\n",
    "    classattr = doc('p.update > span > span').attr('class')\n",
    "    pattern = '</style><span.*?%s.*?>(.*?)</span>'%classattr\n",
    "    #获取当前页面所有被字数字符\n",
    "    numberlist = re.findall(pattern,response)\n",
    "    #获取当前包含字体文件链接的文本\n",
    "    fonturl = doc('p.update > span > style').text() \n",
    "    #通过正则获取当前页面字体文件链接\n",
    "    url = re.search('woff.*?url.*?\\'(.+?)\\'.*?truetype',fonturl) .group(1)\n",
    "    cmap = get_font(url)\n",
    "    books = doc('.all-img-list li').items()\n",
    "    i = 0\n",
    "    df = pd.DataFrame()\n",
    "    for book in books:\n",
    "        item = {}\n",
    "        item['bookname'] = book('.book-mid-info h4 a').text()\n",
    "        item['author'] = book('.name').text()\n",
    "        item['classes'] = book('p.author > a:nth-child(4)').text()\n",
    "        item['content'] = book('.intro').text()\n",
    "        item['number'] = get_encode(cmap,numberlist[i][:-1])\n",
    "        i += 1\n",
    "        df = df.append(item, ignore_index=True)\n",
    "    return df\n",
    "\n",
    "url = start_url\n",
    "get_index(url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# problem is here!\n",
    "# where is mongo?\n",
    "# where is my data?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "di = {'bookname': '修真四万年',\n",
    "  'author': '卧牛真人',\n",
    "  'classes': '科幻',\n",
    "  'content': '“倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！”“哪怕这火花再微弱，再短暂，再渺小，可是只要我们源源不断，前赴后继，终有一日，火花会点燃杂草，杂草会燎到灌',\n",
    "  'number': '1040.22'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame(di,index=[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bookname</th>\n",
       "      <th>author</th>\n",
       "      <th>classes</th>\n",
       "      <th>content</th>\n",
       "      <th>number</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>修真四万年</td>\n",
       "      <td>卧牛真人</td>\n",
       "      <td>科幻</td>\n",
       "      <td>“倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！...</td>\n",
       "      <td>1040.22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  bookname author classes                                            content  \\\n",
       "0    修真四万年   卧牛真人      科幻  “倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！...   \n",
       "\n",
       "    number  \n",
       "0  1040.22  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = {'bookname': '大魏宫廷',\n",
    "  'author': '贱宗首席弟子',\n",
    "  'classes': '历史',\n",
    "  'content': '生作大魏皇子，愿当盛世闲王。志在偎红倚翠犬马声色，胸怀家国百姓社稷安危。若兄贤，若弟明，尔为人王吾偷闲。若尔不能使国强，吾来登基做帝王！————弘润《你不行我上》',\n",
    "  'number': '674.68'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "df1 =  pd.DataFrame(d1,index=[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bookname</th>\n",
       "      <th>author</th>\n",
       "      <th>classes</th>\n",
       "      <th>content</th>\n",
       "      <th>number</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>大魏宫廷</td>\n",
       "      <td>贱宗首席弟子</td>\n",
       "      <td>历史</td>\n",
       "      <td>生作大魏皇子，愿当盛世闲王。志在偎红倚翠犬马声色，胸怀家国百姓社稷安危。若兄贤，若弟明，尔为...</td>\n",
       "      <td>674.68</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  bookname  author classes                                            content  \\\n",
       "0     大魏宫廷  贱宗首席弟子      历史  生作大魏皇子，愿当盛世闲王。志在偎红倚翠犬马声色，胸怀家国百姓社稷安危。若兄贤，若弟明，尔为...   \n",
       "\n",
       "   number  \n",
       "0  674.68  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "result = df1.append(di, ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bookname</th>\n",
       "      <th>author</th>\n",
       "      <th>classes</th>\n",
       "      <th>content</th>\n",
       "      <th>number</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>大魏宫廷</td>\n",
       "      <td>贱宗首席弟子</td>\n",
       "      <td>历史</td>\n",
       "      <td>生作大魏皇子，愿当盛世闲王。志在偎红倚翠犬马声色，胸怀家国百姓社稷安危。若兄贤，若弟明，尔为...</td>\n",
       "      <td>674.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>修真四万年</td>\n",
       "      <td>卧牛真人</td>\n",
       "      <td>科幻</td>\n",
       "      <td>“倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！...</td>\n",
       "      <td>1040.22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  bookname  author classes                                            content  \\\n",
       "0     大魏宫廷  贱宗首席弟子      历史  生作大魏皇子，愿当盛世闲王。志在偎红倚翠犬马声色，胸怀家国百姓社稷安危。若兄贤，若弟明，尔为...   \n",
       "1    修真四万年    卧牛真人      科幻  “倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！...   \n",
       "\n",
       "    number  \n",
       "0   674.68  \n",
       "1  1040.22  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "df2 = pd.DataFrame()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>author</th>\n",
       "      <th>bookname</th>\n",
       "      <th>classes</th>\n",
       "      <th>content</th>\n",
       "      <th>number</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>卧牛真人</td>\n",
       "      <td>修真四万年</td>\n",
       "      <td>科幻</td>\n",
       "      <td>“倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！...</td>\n",
       "      <td>1040.22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  author bookname classes                                            content  \\\n",
       "0   卧牛真人    修真四万年      科幻  “倘若这宇宙，真是一片残酷血腥的黑暗森林，我们修真者，也会燃烧自己的生命，绽放出微弱的火花！...   \n",
       "\n",
       "    number  \n",
       "0  1040.22  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.append(di, ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#方法有问题"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
